import os,sys

new_file_name = sys.argv[1]#'ChangeName'#sys.argv[1]
current_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
file_path = os.path.join(current_path, 'CMakeLists.txt')
file_path_tmp = os.path.join(current_path, 'CMakeLists.txt.bk')
os.rename(file_path, file_path_tmp)

new_file_name_lower = new_file_name.lower()
replace_list = ['TutorialRecommended', 'tutorialrecommended', 'recommended']

with open(file_path_tmp, 'r') as f:
    context = f.read()

context = context.replace(replace_list[0], new_file_name)
context = context.replace(replace_list[1], new_file_name_lower)
context = context.replace(replace_list[2], new_file_name_lower)
context = context.replace('https://github.com/triton-inference-server/common.git', 'https://gitee.com/luo_zhi_cheng/triton-common')
context = context.replace('https://github.com/triton-inference-server/core.git', 'https://gitee.com/luo_zhi_cheng/triton-core')
context = context.replace('https://github.com/triton-inference-server/backend.git', 'https://gitee.com/luo_zhi_cheng/triton-backend')

with open(file_path, 'w') as f:
    f.write(context)

os.remove(file_path_tmp)

print('finish')
